vcCore - Module
vcCore module.
See in: Overview
Classes (top-level): vcApplication, vcBackfaceMode, vcBitmapFileFormat, vcBitmapFormat, vcChartDataType, vcChartTileType, ... (see more)
vcApplication
vcBackfaceMode
vcBitmapFileFormat
vcBitmapFormat
vcChartDataType
vcChartTileType
vcChartType
vcClippingMode
vcCollisionTestMethod
vcColor
vcConnectorTestLocation
vcConnectorType
vcContext
vcContextItem
vcContextManager
vcEdgeShadingMode
vcEvent
vcExpressionPropertyType
vcFocusModeDynamicSetting
vcIterator
vcJointAxis
vcJointServoType
vcJointType
vcLayerManager
vcLayoutItemType
vcLicenseInformation
vcLightType
vcLimitPropertyType
vcList
vcListPropertyType
vcLocalizable
vcLocalizationService
vcMaterialColorMaskFlags
vcMaterialDepthComparison
vcMaterialInheritance
vcMaterialOpacityType
vcMaterialRenderOrder
vcMatrix
vcMatrixFormat
vcMenuTool
vcMessage
vcMessageBox
vcMessageBoxButton
vcMessageBoxImage
vcMessageBoxResult
vcMessageScope
vcMessageService
vcMessageType
vcMoveType
vcNodeListEntry
vcNodeListEntryScope
vcNodeListEntryType
vcNodeSynchronizationType
vcNodeTreeScope
vcObject
vcPackFolderState
vcPdfExportLevel
vcPdfRecorder
vcPickedTopologyCurveInfo
vcPropertyType
vcQuantityKind
vcRaycast
vcRaycastResult
vcReferencePropertyType
vcRenderShadingMode
vcRobotSelectionService
vcRuntimeConfig
vcSelectionManager
vcSimNodeType
vcSimulationLevel
vcSimulationState
vcSnapService
vcStatisticsDashboard
vcStepPropertyType
vcSweptVolumeDecompositionType
vcSweptVolumeMethod
vcTopologyPickService
vcUnitManager
vcVector
vcVideoRecorder
vcViewFlags
vcVolumeDetectorTestMethod
vcTask
Enums: vcBackfaceMode, vcBitmapFileFormat, vcBitmapFormat, vcChartDataType, vcChartTileType, vcChartType, ... (see more)
vcBackfaceMode
vcBitmapFileFormat
vcBitmapFormat
vcChartDataType
vcChartTileType
vcChartType
vcClippingMode
vcCollisionTestMethod
vcConnectorTestLocation
vcConnectorType
vcEdgeShadingMode
vcEnumPropertyType
vcExpressionPropertyType
vcFocusModeDynamicSetting
vcJointAxis
vcJointServoType
vcJointType
vcLayoutItemType
vcLightType
vcLimitPropertyType
vcListPropertyType
vcMaterialColorMaskFlags
vcMaterialDepthComparison
vcMaterialInheritance
vcMaterialOpacityType
vcMaterialRenderOrder
vcMatrixFormat
vcMenuTool
vcMessageBoxButton
vcMessageBoxImage
vcMessageBoxResult
vcMessageType
vcMoveType
vcNodeListEntryScope
vcNodeListEntryType
vcNodeSynchronizationType
vcNodeTreeScope
vcPackFolderState
vcPdfExportLevel
vcPropertyType
vcQuantityKind
vcReferencePropertyType
vcRenderShadingMode
vcSimNodeType
vcSimulationLevel
vcSimulationState
vcStepPropertyType
vcSweptVolumeDecompositionType
vcSweptVolumeMethod
vcViewFlags
vcVolumeDetectorTestMethod
Methods
Learn how to use methods here. The methods are also inherited from the parent class.
| Name | Return Type | Parameters | Description |
| allTasks | vcTask | list tasks, Optional Keyword[autoCancel = Boolean] |
Blocks script execution until all of subtasks have completed. This function returns an awaitable task. It must be awaited. See moreParamaters: tasks (vcTask[]): A list of tasks to await. Optional: autoCancel (Boolean): True by default. When autoCancel is True, will cancel all pending subtasks automatically on return. Returns: Awaitable: task that must be awaited. |
| anyTask | vcTask | list tasks, Optional Keyword[autoCancel = Boolean], Optional Keyword[waitTrigger = Boolean] |
Blocks script execution until any of subtasks have completed. This function returns an awaitable task. It must be awaited. See moreParamaters: tasks (vcTask[]): A list of vcTasks to await. Optional: autoCancel (Boolean): True by default. When autoCancel is True, will cancel all pending subtasks automatically on return. Optional: waitTrigger (Boolean): True by default. When waitTrigger is True, will ignore all completed subtasks, waiting only for incomplete tasks to change. When waitTrigger is False and any task is already complete, this task will immediately return. Exceptions: ValueError: When given an empty list of tasks. ValueError: When given tasks are all done and waitTrigger is True. Returns: Awaitable: task that must be awaited. |
| condition | vcTask | function conditional, Real timeout, Optional Keyword[waitTrigger = Boolean] |
Blocks script execution until the conditional returns True. The created task is evaluated automatically on signals or manually on `evaluateConditions()`.
See moreThis function returns an awaitable task. It must be awaited. Parameters: conditional (function): User-defined function that returns True whenever the script can continue its execution. timeout (float): The conditional will pass after `timeout` seconds of simulation time have passed. Off by default. waitTrigger (Boolean): Should the condition wait for a trigger before evaluating the condition. False by default. Returns: Awaitable: task that must be awaited. |
| delay | vcTask | Real seconds | Blocks script execution until certain amount of simulation time has passed.
See moreThis function returns an awaitable task. It must be awaited. Parameters: seconds (Real): The amount of simulation time that has to pass for vcTask to complete. Returns: Awaitable: task that must be awaited. |
| evaluateConditions | None | None | Evaluates conditions for all condition tasks that are in some way blocking this script (either directly or indirectly in task groups). Other tasks are not evaluated. |
| getApplication | vcApplication | None | Returns the application object. Returns: vcApplication: application object. |
| getBehavior | vcBehavior | None | Returns the behavior containing this script.
See moreExceptions: RuntimeError: When called from a script that is not based on behavior. Returns: vcBehavior: Behavior containing this script. |
| getCommand | vcCommand | None | Returns the command object.
See moreExceptions: RuntimeError: When called from a class that is not python command. Returns: vcCommand: command object. |
| getComponent | vcComponent | None | Returns the component containing this script.
See moreExceptions: RuntimeError: When called from a script that is not based on behavior. Returns: vcComponent: component containing this script. |
| getFeature | vcFeature | None | Returns the feature.
See moreExceptions: RuntimeError: When called from a class that is not python feature. Returns: vcFeature: feature object. |
| getFilter | vcPythonProductFilter | None | Returns the filter.
See moreExceptions: RuntimeError: When called from a class that is not python product filter. Returns: vcPythonProductFilter: filter object. |
| getNode | vcNode | None | Returns the node containing this script.
See moreExceptions: RuntimeError: When called from a script that is not based on behavior. Returns: vcNode: node containing this script. |
| getSimulation | vcSimulation | None | Returns the simulation object.
See moreExceptions: RuntimeError: When called from python feature or python product type filter. Returns: vcSimulation: Simulation object. |
| getStatement | vcStatement | None | Returns the statement.
See moreExceptions: RuntimeError: When called from a class that is not python statement. Returns: vcPythonStatement: statement object. |
| getWorld | vcWorld | None | Returns the simulation world containing this script.
See moreFor scripts not tied to a specific world use vcWorldManager instead. Exceptions: RuntimeError: When called from a script that is not tied to a specific world. Returns: vcWorld: The world containing this script. |
Events
The following event handlers are functions that can be defined and used in a script. In most cases, you use the OnRun event to define the main program/loop of script which is executed while a simulation is running.
| Name | Parameters | Description |
| OnAction | vcAction action | Triggered when an Action Container connected to script handles an action. |
| OnContinue | None | Triggered when a simulation resumes after being halted. |
| OnDestroy | None | Triggered when an object is destroyed, for example a node. |
| OnFinalize | None | Triggered when layout or component is being loaded in 3D world.
The event occurs, for example, when copying a component, or loading a layout of components. The event is triggered before the needed components are attached to the 3D world. |
| OnRebuild | None | Triggered when component geometry is rebuilt. |
| OnReset | None | Triggered when simulation is reset to its initial state and simulation clock is set at zero. |
| OnRun | None | Triggered at the start of a simulation and is used as the main function/loop of script. |
| OnSignal | vcSignal signal | Triggered when a signal connected to script signals its value. |
| OnSimulationUpdate | Real time | Triggered when simulation and scene are updated. |
| OnSimulationLevelChanged | Enum |
Triggered when the simulation level is changed. Refers to SimulationLevel Property in vcComponent. |
| OnStart | None | Triggered at the immediate start of simulation. |
| OnStop | None | Triggered when a simulation is halted. |
Example: Import vcCore
"""Import module with an alias name.""" import vcCore as vc
Example: Wait Condition for Multiple Signal Values
"""This script shows how to wait a multi-signal condition to be true. Note that the condition is evaluated when signal values update or when the evaluation is manually triggered with the evaluateConditions() method from vcCore. """ import vcCore as vc comp = vc.getComponent() sensor_sig_1 = comp.findBehavior("SensorSignal_1") sensor_sig_2 = comp.findBehavior("SensorSignal_2") async def OnRun(): await vc.condition(lambda trigger: sensor_sig_1.Value and sensor_sig_2.Value) # "trigger" argument # stores the object that triggered the condition and can be used inside the condition evaluation print ("Sensor signals true")
Example: Wait Events As vcTasks
""" The script shows how to wait for change events from a pool of events. The events are first converted as vcTasks. """ import vcCore as vc async def OnRun(): comp = vc.getComponent() signal_1 = comp.findBehavior("BooleanSignal_1") signal_2 = comp.findBehavior("BooleanSignal_2") signal_3 = comp.findBehavior("BooleanSignal_3") e1_signal = comp.findBehavior("EmergencySignal_1") e1_time = 60 # seconds process_time = 10 # seconds while True: # recreate the awaitable tasks for the signals before the anyTask call t1 = signal_1.OnSignal.wait() # Converts OnSignal event to an awaitable task t2 = signal_2.OnSignal.wait() t3 = signal_3.OnSignal.wait() e1 = e1_signal.OnSignal.wait() await vc.anyTask([t1,t2,t3,e1]) # wait for any of the awaitable tasks to complete if e1_signal.Value: # emergency routine vc.delay(e1_time) if signal_1.Value == True and signal_2.Value and signal_3.Value: # start process vc.delay(process_time)